package com.cwl.config;

import com.cwl.common.sn.SnService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.support.atomic.RedisAtomicLong;

/**
 * 功能描述：
 *
 * @author cwledit
 * @date 2018/9/20
 */
@Configuration
@ConditionalOnMissingBean(name = "commonSeq")
public class SnConfig {

    @Autowired
    private RedisConnectionFactory factory;

    @Bean(name = "tradeSeq")
    public RedisAtomicLong transSeq() {
        return new RedisAtomicLong("tradeSeq", factory, 1L);
    }

    @Bean(name = "recordSeq")
    public RedisAtomicLong recordSeq() {
        return new RedisAtomicLong("recordSeq", factory, 1L);
    }

    @Bean(name = "refundSeq")
    public RedisAtomicLong refundSeq() {
        return new RedisAtomicLong("refundSeq", factory, 1L);
    }

    @Bean(name = "checkRecordSeq")
    public RedisAtomicLong checkRecordSeq() {
        return new RedisAtomicLong("checkRecordSeq", factory, 1L);
    }

    @Bean(name = "commonSeq")
    public RedisAtomicLong commonSeq() {
        return new RedisAtomicLong("commonSeq", factory, 1L);
    }

    @Bean(name = "preOrderSeq")
    public RedisAtomicLong preOrderSeq() {
        return new RedisAtomicLong("preOrderSeq", factory, 1L);
    }

    @Bean(name = "chargeItemSeq")
    public RedisAtomicLong getChargeItemSeq() {
        return new RedisAtomicLong("chargeItemSeq", factory, 1L);
    }

    @Bean(name = "chargeSubjectSeq")
    public RedisAtomicLong getChargeSubjectSeq() {
        return new RedisAtomicLong("chargeSubjectSeq", factory, 1L);
    }

    @Bean(name = "appSeq")
    public RedisAtomicLong getAppSeq() {
        return new RedisAtomicLong("appSeq", factory, 1L);
    }

    @Bean(name = "ScreenSeq")
    public RedisAtomicLong getScreenSeq() {
        return new RedisAtomicLong("ScreenSeq", factory, 1L);
    }

    @Bean(name = "SignSeq")
    public RedisAtomicLong getSignSeq() {
        return new RedisAtomicLong("SignSeq", factory, 1L);
    }

    @Bean(name = "CallingSeq")
    public RedisAtomicLong getCallingSeq() {
        return new RedisAtomicLong("CallingSeq", factory, 1L);
    }

    @Bean(name = "QueueSeq")
    public RedisAtomicLong getQueueSeq() {
        return new RedisAtomicLong("QueueSeq", factory, 1L);
    }

    @Bean(name = "snService")
    @ConditionalOnMissingBean(SnService.class)
    public SnService snService(){
        SnService snService = new SnService();
        return snService;
    }
}
